/*
 * @Author: xiaosihan
 * @Date: 2024-10-05 18:50:38
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-10-06 21:03:03
 */

import { FactoryUser } from "@type";
import { observable, configure } from "mobx";
configure({ enforceActions: "never" });

export type LoginStatus =
  | "login"
  | "register"
  | "accountInfo"
  | "companyInfo"
  | "made"
  | "introduce";

const factoryStore = (window.factoryStore = observable(
  {
    loginStatus: "login" as LoginStatus,
    setLoginStatus(loginStatus: LoginStatus) {
      this.loginStatus = loginStatus;
    },

    // 是否登录了
    isLogin: undefined as boolean | undefined,
    setIsLogin(val: boolean | undefined) {
      this.isLogin = val;
    },

    // 工厂端用户的信息
    factoryUser: undefined as FactoryUser | undefined,
    // 获取工厂端用户的信息
    getFactoryUser() {
      this.isLogin = true;
    },

    //退出登录
    loginOut() {
      this.setIsLogin(false);
      this.setLoginStatus("login");
    },
  },
  {},
  { deep: false }
));
export default factoryStore;
